import styles from './index.less';
import Drugapi from '../api/drug.api'
import HTTP from '../services/api';
import { Table, message, notification } from 'antd'
import React from 'react';
const columns = [
    {
        title: '药品名称',
        dataIndex: 'drug_name',
    },
    {
        title: '药品的价格',
        dataIndex: 'price',
    },
    {
        title: '药品的数量',
        dataIndex: 'count',
    },
    {
        title: '药品的规格',
        dataIndex: 'specification',
    },
    {
        title: '药品的单位',
        dataIndex: 'unit',
    },
    {
        title: '备注',
        dataIndex: 'comment'
    }
];

export default class Grug extends React.Component {
    constructor() {
        super()
        this.state = {
            durginfo: []
        }
    }

    getAllDrugInfo = async () => {
        let result = await HTTP({ method: 'get' }, Drugapi.getAllDrugInfo)
        if (result && result.status) {
            // message.info(result.msg)
            notification.success({
                message: result.msg,
                description:`获取到药品种类有${result.info.count}`,
                onClick: () => {
                    console.log('Notification Clicked!')
                }
            }
            )
            this.setState({ durginfo: result.info.rows })
        }
        else {
            message.error(result.msg)

        }
        console.log(result)

    }
    componentDidMount() {
        this.getAllDrugInfo()
    }
    render() {
        let { durginfo } = this.state
        return (
            <div>
                <Table key='drug_id' dataSource={durginfo} columns={columns}></Table>
            </div>
        );
    }

}




